import graph.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;


public class Client {

	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException {
		System.out.println("Enter the filename: ");
		Scanner user_input = new Scanner( System.in );
		String filename = user_input.next();
		Set<Vertex> vertices = new LinkedHashSet<Vertex>();
		Set<Edge> edges = new LinkedHashSet<Edge>();
		// Prepare to read from the file, using a Scanner object
		File file = new File(filename);
		Scanner in = new Scanner(file);

		//second line down
		String line = in.nextLine();
		String line2 = in.nextLine();
		String[] curr_line = line2.split(" ");
		for (int i = 0; i < curr_line.length; i++){
			vertices.add(new Vertex(curr_line[i]));
		}
		while (in.hasNext()) {
			String line3_onward = in.nextLine();
			String[] curr_line1 = line3_onward.split(" ");
			edges.add(new Edge (new Vertex (curr_line1[0]), new Vertex (curr_line1[1]), Double.parseDouble(curr_line1[2])));
		}
		//}

		user_input.close();
		Graph gr = new Graph(vertices, edges);
		System.out.println(gr.totalEdgeCost());
		System.out.println(gr);
		System.out.println(gr.isConnected());
		System.out.println(gr.isRedConnected());

	}

}
